/*
 * Copyright © 2004-2014 chenYuan. All rights reserved.
 * @Website:wwww.jspx.net
 * @Mail:39793751@qq.com
 * @author: chenYuan , 陈原
 * @License: Jspx.net Framework Code is open source (LGPL)，Jspx.net Framework 使用LGPL 开源授权协议发布。
 * @jvm:jdk1.6+  x86/amd64
 *
 */
package com.jspx.sober.criteria.projection;

/**
 * Created by IntelliJ IDEA.
 * User:chenYuan (mail:39793751@qq.com)
 * Date: 2007-1-9
 * Time: 23:35:04
 */
public final class Projections
{

    private Projections()
    {
        //cannot be instantiated
    }

    /**
     * Create a distinct projection from a projection
     */
    public static Projection distinct(Projection proj)
    {
        return new Distinct(proj);
    }

    /**
     * Create a new projection list
     */
    public static ProjectionList projectionList()
    {
        return new ProjectionList();
    }

    /**
     * The query row count, ie. <tt>count(*)</tt>
     */
    public static Projection rowCount()
    {
        return new RowCountProjection();
    }

    /**
     * A property value count
     */
    public static CountProjection count(String propertyName)
    {
        return new CountProjection(propertyName);
    }

    /**
     * A distinct property value count
     */
    public static CountProjection countDistinct(String propertyName)
    {
        return new CountProjection(propertyName).setDistinct();
    }

    /**
     * A property maximum value
     */
    public static AggregateProjection max(String propertyName)
    {
        return new AggregateProjection("max", propertyName);
    }

    /**
     * A property minimum value
     */
    public static AggregateProjection min(String propertyName)
    {
        return new AggregateProjection("min", propertyName);
    }

    /**
     * A property average value
     */
    public static AggregateProjection avg(String propertyName)
    {
        return new AvgProjection(propertyName);
    }

    /**
     * A property value sum
     */
    public static AggregateProjection sum(String propertyName)
    {
        return new AggregateProjection("sum", propertyName);
    }

    public static SQLProjection sql(String propertyName)
    {
        return new SQLProjection(propertyName);
    }

    /**
     * Assign an alias to a projection, by wrapping it
     */
    public static Projection alias(Projection projection, String alias)
    {
        return new AliasedProjection(projection, alias);
    }

    public static Projection add(Projection projection1, Projection projection2)
    {
        return new AddProjection(projection1, projection2);
    }

    public static Projection dec(Projection projection1, Projection projection2)
    {
        return new DecProjection(projection1, projection2);
    }

    public static Projection mul(Projection projection1, Projection projection2)
    {
        return new MulProjection(projection1, projection2);
    }

    public static Projection div(Projection projection1, Projection projection2)
    {
        return new DivProjection(projection1, projection2);
    }
}